package work.endlove.kuikly_demo.pages

import com.tencent.kuikly.core.annotations.Page
import com.tencent.kuikly.core.base.Border
import com.tencent.kuikly.core.base.BorderStyle
import com.tencent.kuikly.core.base.Color
import com.tencent.kuikly.core.base.ViewBuilder
import com.tencent.kuikly.core.log.KLog
import com.tencent.kuikly.core.views.PlayState
import com.tencent.kuikly.core.views.Video
import com.tencent.kuikly.core.views.VideoPlayControl
import work.endlove.kuikly_demo.base.BasePager
import work.endlove.kuikly_demo.base.NavBar

@Page("hello_video")
internal class VideoExamplePage : BasePager() {

    override fun body(): ViewBuilder {
        val ctx = this
        return {
            attr {
                backgroundColor(Color.BLACK)
            }
            NavBar {
                attr {
                    title = "VideoExamplePage"
                }
            }

            Video {
                attr {
//                    src("http://vjs.zencdn.net/v/oceans.mp4")
                    playControl(VideoPlayControl.PLAY)
                    height(300f)
                    margin(20f)
                    border(
                        border = Border(
                            lineStyle = BorderStyle.SOLID,
                            color = Color.BLACK,
                            lineWidth = 1f,
                        )
                    )
                }

                event {
                    playStateDidChanged { state, extInfo ->
                        if (state == PlayState.PLAYING) {
                            KLog.i("333333","uyiuyuyu")
                        }
                    }
                }
            }
        }
    }
}